﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace DataStructures
{
    public class Collections
    {
        /// <summary>
        /// Stack Shema
        /// </summary>
        interface iStack
        {
            
            void Push(object data);
            object Pop();

        }

        /// <summary>
        /// Entry Data 
        /// </summary>
        class Entry
        {
            public Entry next;
            public object data;

            public Entry(Entry next, object data)
            {
                this.next = next;
                this.data = data;
            }

        }

        /// <summary>
        /// Stack Program
        /// </summary>
       public class Stack: iStack
       {
           Entry top;

           public void Push(object data)
           {
               top = new Entry(top, data);
           }

           public object Pop()
           {
               if (top == null) throw new InvalidOperationException();
               object result = top.data;
               top = top.next;
               return result;

           }
       }

    

        
    }
}
